﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ZK.Common
{
    public class HardWareConfig : ConfigurationSection
    {
        [ConfigurationProperty("ledSmallEnter", IsRequired = true)]
        public MyLedSmallEnterElement LedSmallEnter
        {
            get { return (MyLedSmallEnterElement)this["ledSmallEnter"]; }
        }
        public class MyLedSmallEnterElement : ConfigurationElement
        {
            [ConfigurationProperty("ipStr", IsRequired = true)]
            public string IpStr
            {
                get { return this["ipStr"].ToString(); }
                set { this["ipStr"] = value; }
            }

            [ConfigurationProperty("ledWidth", IsRequired = true)]
            public int LedWidth
            {
                get { return int.Parse(this["ledWidth"].ToString()); }
                set { this["ledWidth"] = value; }
            }

            [ConfigurationProperty("ledHeight", IsRequired = true)]
            public int LedHeight
            {
                get { return int.Parse(this["ledHeight"].ToString()); }
                set { this["ledHeight"] = value; }
            }
        }
        /// <summary>
        /// 地磅监控配置前-节点
        /// </summary>
        [ConfigurationProperty("cameraScalesQ", IsRequired = true)]
        public CameraScalesQElement cameraScalesQ
        {
            get { return (CameraScalesQElement)this["cameraScalesQ"]; }
        }
        /// <summary>
        /// 地磅监控配置前-class
        /// </summary>
        public class CameraScalesQElement : ConfigurationElement
        {
            [ConfigurationProperty("ip", IsRequired = true)]
            public string Ip
            {
                get { return this["ip"].ToString(); }
                set { this["ip"] = value; }
            }

            [ConfigurationProperty("port", IsRequired = true)]
            public int Port
            {
                get { return int.Parse(this["port"].ToString()); }
                set { this["port"] = value; }
            }

            [ConfigurationProperty("userName", IsRequired = true)]
            public string UserName
            {
                get { return this["userName"].ToString(); }
                set { this["userName"] = value; }
            }
            [ConfigurationProperty("passWord", IsRequired = true)]
            public string PassWord
            {
                get { return this["passWord"].ToString(); }
                set { this["passWord"] = value; }
            }
        }

        /// <summary>
        /// 地磅监控配置前-节点
        /// </summary>
        [ConfigurationProperty("cameraScalesG", IsRequired = true)]
        public CameraScalesGElement cameraScalesG
        {
            get { return (CameraScalesGElement)this["cameraScalesG"]; }
        }
        /// <summary>
        /// 地磅监控配置前-class
        /// </summary>
        public class CameraScalesGElement : ConfigurationElement
        {
            [ConfigurationProperty("ip", IsRequired = true)]
            public string Ip
            {
                get { return this["ip"].ToString(); }
                set { this["ip"] = value; }
            }

            [ConfigurationProperty("port", IsRequired = true)]
            public int Port
            {
                get { return int.Parse(this["port"].ToString()); }
                set { this["port"] = value; }
            }

            [ConfigurationProperty("userName", IsRequired = true)]
            public string UserName
            {
                get { return this["userName"].ToString(); }
                set { this["userName"] = value; }
            }
            [ConfigurationProperty("passWord", IsRequired = true)]
            public string PassWord
            {
                get { return this["passWord"].ToString(); }
                set { this["passWord"] = value; }
            }
        }

        /// <summary>
        /// 地磅监控配置前-节点
        /// </summary>
        [ConfigurationProperty("cameraScalesH", IsRequired = true)]
        public CameraScalesHElement cameraScalesH
        {
            get { return (CameraScalesHElement)this["cameraScalesH"]; }
        }
        /// <summary>
        /// 地磅监控配置前-class
        /// </summary>
        public class CameraScalesHElement : ConfigurationElement
        {
            [ConfigurationProperty("ip", IsRequired = true)]
            public string Ip
            {
                get { return this["ip"].ToString(); }
                set { this["ip"] = value; }
            }

            [ConfigurationProperty("port", IsRequired = true)]
            public int Port
            {
                get { return int.Parse(this["port"].ToString()); }
                set { this["port"] = value; }
            }

            [ConfigurationProperty("userName", IsRequired = true)]
            public string UserName
            {
                get { return this["userName"].ToString(); }
                set { this["userName"] = value; }
            }
            [ConfigurationProperty("passWord", IsRequired = true)]
            public string PassWord
            {
                get { return this["passWord"].ToString(); }
                set { this["passWord"] = value; }
            }
        }



        [ConfigurationProperty("ledSmallOut", IsRequired = true)]
        public MyLedSmallOutElement LedSmallOut
        {
            get { return (MyLedSmallOutElement)this["ledSmallOut"]; }
        }
        public class MyLedSmallOutElement : ConfigurationElement
        {
            [ConfigurationProperty("ipStr")]
            public string IpStr
            {
                get { return this["ipStr"].ToString(); }
                set { this["ipStr"] = value; }
            }

            [ConfigurationProperty("ledWidth")]
            public int LedWidth
            {
                get { return int.Parse(this["ledWidth"].ToString()); }
                set { this["ledWidth"] = value; }
            }

            [ConfigurationProperty("ledHeight")]
            public int LedHeight
            {
                get { return int.Parse(this["ledHeight"].ToString()); }
                set { this["ledHeight"] = value; }
            }
        }

        [ConfigurationProperty("cameraEnter", IsRequired = true)]
        public MyCameraEnterElement CameraEnter
        {
            get { return (MyCameraEnterElement)this["cameraEnter"]; }
        }
        public class MyCameraEnterElement : ConfigurationElement
        {
            [ConfigurationProperty("cameraIp")]
            public string CameraIp
            {
                get { return this["cameraIp"].ToString(); }
                set { this["cameraIp"] = value; }
            }

            [ConfigurationProperty("cameraPort")]
            public int CameraPort
            {
                get { return Utility.StringToIntParse(this["cameraPort"].ToString()); }
                set { this["cameraPort"] = value; }
            }

            [ConfigurationProperty("userName")]
            public string UserName
            {
                get { return this["userName"].ToString(); }
                set { this["userName"] = value; }
            }

            [ConfigurationProperty("password")]
            public string Password
            {
                get { return this["password"].ToString(); }
                set { this["password"] = value; }
            }
        }

        [ConfigurationProperty("cameraOut", IsRequired = true)]
        public MyCameraOutElement CameraOut
        {
            get { return (MyCameraOutElement)this["cameraOut"]; }
        }
        public class MyCameraOutElement : ConfigurationElement
        {
            [ConfigurationProperty("cameraIp")]
            public string CameraIp
            {
                get { return this["cameraIp"].ToString(); }
                set { this["cameraIp"] = value; }
            }

            [ConfigurationProperty("cameraPort")]
            public int CameraPort
            {
                get { return Utility.StringToIntParse(this["cameraPort"].ToString()); }
                set { this["cameraPort"] = value; }
            }

            [ConfigurationProperty("userName")]
            public string UserName
            {
                get { return this["userName"].ToString(); }
                set { this["userName"] = value; }
            }

            [ConfigurationProperty("password")]
            public string Password
            {
                get { return this["password"].ToString(); }
                set { this["password"] = value; }
            }
        }


        [ConfigurationProperty("cameraMonitor", IsRequired = true)]
        public MyCameraMonitorElement CameraMonitor
        {
            get { return (MyCameraMonitorElement)this["cameraMonitor"]; }
        }
        public class MyCameraMonitorElement : ConfigurationElement
        {
            [ConfigurationProperty("cameraIp")]
            public string CameraIp
            {
                get { return this["cameraIp"].ToString(); }
                set { this["cameraIp"] = value; }
            }

            [ConfigurationProperty("cameraPort")]
            public int CameraPort
            {
                get { return Utility.StringToIntParse(this["cameraPort"].ToString()); }
                set { this["cameraPort"] = value; }
            }

            [ConfigurationProperty("userName")]
            public string UserName
            {
                get { return this["userName"].ToString(); }
                set { this["userName"] = value; }
            }

            [ConfigurationProperty("password")]
            public string Password
            {
                get { return this["password"].ToString(); }
                set { this["password"] = value; }
            }
        }


        [ConfigurationProperty("readerEnter", IsRequired = true)]
        public MyReaderEnterElement ReaderEnter
        {
            get { return (MyReaderEnterElement)this["readerEnter"]; }
        }
        public class MyReaderEnterElement : ConfigurationElement
        {
            [ConfigurationProperty("readerIp")]
            public string ReaderIp
            {
                get { return this["readerIp"].ToString(); }
                set { this["readerIp"] = value; }
            }

            [ConfigurationProperty("readerPort")]
            public int ReaderPort
            {
                get { return Utility.StringToIntParse(this["readerPort"].ToString()); }
                set { this["readerPort"] = value; }
            }
        }


        [ConfigurationProperty("readerOut", IsRequired = true)]
        public MyReaderOutElement ReaderOut
        {
            get { return (MyReaderOutElement)this["readerOut"]; }
        }
        public class MyReaderOutElement : ConfigurationElement
        {
            [ConfigurationProperty("readerIp")]
            public string ReaderIp
            {
                get { return this["readerIp"].ToString(); }
                set { this["readerIp"] = value; }
            }

            [ConfigurationProperty("readerPort")]
            public int ReaderPort
            {
                get { return Utility.StringToIntParse(this["readerPort"].ToString()); }
                set { this["readerPort"] = value; }
            }
        }
        /// <summary>
        /// 地磅节点
        /// </summary>
        [ConfigurationProperty("wagonBalance", IsRequired = true)]
        public MyWagonBalanceElement WagonBalance
        {
            get { return (MyWagonBalanceElement)this["wagonBalance"]; }
        }
        public class MyWagonBalanceElement : ConfigurationElement
        {
            [ConfigurationProperty("name")]
            public string Name
            {
                get { return this["name"].ToString(); }
                set { this["name"] = value; }
            }

            [ConfigurationProperty("portName")]
            public string PortName
            {
                get { return this["portName"].ToString(); }
                set { this["portName"] = value; }
            }

            [ConfigurationProperty("baudRate")]
            public int BaudRate
            {
                get { return int.Parse(this["baudRate"].ToString()); }
                set { this["baudRate"] = value; }
            }

            [ConfigurationProperty("dataBits")]
            public int DataBits
            {
                get { return int.Parse(this["dataBits"].ToString()); }
                set { this["dataBits"] = value; }
            }
        }

        [ConfigurationProperty("trafficLight", IsRequired = true)]
        public MyTrafficLightElement TrafficLight
        {
            get { return (MyTrafficLightElement)this["trafficLight"]; }
        }
        public class MyTrafficLightElement : ConfigurationElement
        {
            [ConfigurationProperty("name")]
            public string Name
            {
                get { return this["name"].ToString(); }
                set { this["name"] = value; }
            }

            [ConfigurationProperty("portName")]
            public string PortName
            {
                get { return this["portName"].ToString(); }
                set { this["portName"] = value; }
            }

            [ConfigurationProperty("baudRate")]
            public int BaudRate
            {
                get { return int.Parse(this["baudRate"].ToString()); }
                set { this["baudRate"] = value; }
            }

            [ConfigurationProperty("dataBits")]
            public int DataBits
            {
                get { return int.Parse(this["dataBits"].ToString()); }
                set { this["dataBits"] = value; }
            }
        }

        [ConfigurationProperty("infrared", IsRequired = true)]
        public MyInfraredElement Infrared
        {
            get { return (MyInfraredElement)this["infrared"]; }
        }
        /// <summary>
        /// 红外光栅
        /// </summary>
        public class MyInfraredElement : ConfigurationElement
        {
            /// <summary>
            /// 名字
            /// </summary>
            [ConfigurationProperty("name")]
            public string Name
            {
                get { return this["name"].ToString(); }
                set { this["name"] = value; }
            }
            /// <summary>
            /// 端口号
            /// </summary>
            [ConfigurationProperty("portName")]
            public string PortName
            {
                get { return this["portName"].ToString(); }
                set { this["portName"] = value; }
            }
            /// <summary>
            /// 波特率
            /// </summary>
            [ConfigurationProperty("baudRate")]
            public int BaudRate
            {
                get { return int.Parse(this["baudRate"].ToString()); }
                set { this["baudRate"] = value; }
            }
            /// <summary>
            /// 数据库
            /// </summary>
            [ConfigurationProperty("dataBits")]
            public int DataBits
            {
                get { return int.Parse(this["dataBits"].ToString()); }
                set { this["dataBits"] = value; }
            }
            /// <summary>
            /// 启用
            /// </summary>
            [ConfigurationProperty("isEnabled")]
            public int IsEnabled
            {
                get { return int.Parse(this["isEnabled"].ToString()); }
                set { this["isEnabled"] = value; }
            }
        }
    }
}
